﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;

public class StartPanel : View {
    public Slider progress;
    public Text Text;
    List<string> msgList = new List<string>()
    {
        NotiConst.ExtractPercent,
        NotiConst.DownloadPercent,
        NotiConst.DownloadComplete,
    };
    private void Awake()
    {
        RegisterMessage(this, msgList); //注册消息
    }
    float percent;
    string msginfo;
    public override void OnMessage(IMessage message)
    {
        string name = message.Name;
        object body = message.Body;
        switch (name)
        {
            case NotiConst.ExtractPercent://解压进度
                percent = (float)body;
                float v = percent * 100;
                msginfo = "正在解压:" + v.ToString("00")+"%";
                break;
            case NotiConst.DownloadPercent://下载进度
                percent = (float)body;
                v = percent * 100;
                msginfo= "正在下载:" + v.ToString("00") + "%";
                break;
            case NotiConst.DownloadComplete://下载完成
                Destroy(this.gameObject);
                break;
            default:
                break;
        }
    }
    private void Update()
    {
        Text.text = msginfo;
        progress.value = percent;
    }
}
